using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.Design;
using System.Security.Policy;
using System.Text;
using System.Windows.Media;
using System.Xml.Linq;

namespace RRX.Xml.ProjectTree
{
    public class ItemProjectTreeLine : INotifyPropertyChanged, IItemProjectTree
    {

        public ItemProjectTreeLine() {}




        // ---------- Properties ----------
        private string name { get; set; } = "Line";
        public string Name
        {
            get => name;
            set
            {
                name = value;
                OnPropertyChanged("Name");
            }
        }

        private string points { get; set; } = "570;210|605;215";
        public string Points
        {
            get => points;
            set
            {
                points = value;
                OnPropertyChanged("Points");
            }
        }





        // ---------- Basic ----------
        private ObservableCollection<IItemProjectTree> children { get; set; } = new ObservableCollection<IItemProjectTree>();
        public ObservableCollection<IItemProjectTree> Children
        {
            get => children;
            set
            {
                children = value;
                OnPropertyChanged("Children");
            }
        }



        // ---------- Functions ----------
        public IItemProjectTree Copy()
        {
            ItemProjectTreeLine copy = new ItemProjectTreeLine();
            copy.name = name;
            copy.points = points;

            return copy;
        }

        public XElement Xml()
        {
            XElement xml = new XElement("x.lin");
            xml.SetAttributeValue("pts", points);

            return xml;
        }


        // ---------- PropertyChanged ----------
        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string name)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
        }
    }
}
